package com.wlz.aop;

import com.wlz.config.AppConfig2;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author wlz
 * @date 2022-05-28  9:20 下午
 */
public class MainStarter2 {

	public static void main(String[] args) {
		// @AspectJ 配置
		test1();
		//  xml 配置
//		test2();
	}

	/**
	 * @AspectJ 配置
	 */
	public static void test1() {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig2.class);
		for (String beanDefinitionName : context.getBeanDefinitionNames()) {
			System.out.println(beanDefinitionName);
		}

		Calculate calculate = context.getBean("myCalculate",Calculate.class);
		calculate.add(1,1);
	}

	/**
	 *  xml 配置
	 */
	public static void test2(){
		ClassPathXmlApplicationContext context =
				new ClassPathXmlApplicationContext("spring-aop1.xml");
		for (String beanDefinitionName : context.getBeanDefinitionNames()) {
			System.out.println(beanDefinitionName);
		}

		Calculate calculate = context.getBean("myCalculate",Calculate.class);
		calculate.div(1,1);

	}

}
